let open = false
$('.t-user').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-user').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!(/^1[3-9]\d{9}$/.test(($(".t-user").val())))){
        $('.t-none').css('display', 'block');
        $('.t-number').html('*请输入正确的手机号');
        open = false
    }else{
        $('.t-number').html('*可以注册')
        open = true
    }
});

let open1 = false
$('.t-email').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-email').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!(/^\w+@\w{2,}(.com|.cn|.163|.org)$/.test(($(".t-email").val())))){
        $('.t-empty').html('*邮件地址不合法')
        open1 = false
    }else{
        $('.t-empty').html('*可以注册')
        open1 = true
    }
});


let open2 = false
$('.t-word').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-word').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(($(".t-word").value = this.value.replace(/^.{6,}$/,'')) || !($(".t-word").value = this.value.replace(/\s/,''))){
        $('.t-six').html('*登录密码不能少于 6 个字符。')
        open2 = false
    }else{
        $('.t-six').html('*可以注册')
        open2 = true
    }
});


let open3 = false
$('.t-confirm').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-confirm').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-word").value = this.value.replace(/\s/,''))){
        $('.t-nosame').html('*登录密码不能少于 6 个字符。')
        open3 = false
    }else if(!($('.t-confirm').prop('value') === $('.t-word').prop('value')) ){
        $('.t-nosame').html('*两次密码输入的不一致')
        open3 = false
    }
    else{
        $('.t-nosame').html('*可以注册')
        open3 = true
    }
});
let open4 = false
$('.t-name').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-name').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-name").value = this.value.replace(/\s/,''))){
        open4 = false
    }else{
        open4 = true
    }
});

let open5 = false
$('.t-gender').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-gender').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-gender").value = this.value.replace(/\s/,''))){
        open5 = false
    }else{
        open5 = true
    }
});
let open6 = false
$('.t-phone').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-phone').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-phone").value = this.value.replace(/\s/,''))){
        open6 = false
    }else{
        open6 = true
    }
});
let open7 = false
$('.t-tele').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-tele').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-tele").value = this.value.replace(/\s/,''))){
        open7 = false
    }else{
        open7 = true
    }
});
let open8 = false
$('.t-flamy').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-flamy').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-flamy").value = this.value.replace(/\s/,''))){
        open8 = false
    }else{
        open8 = true
    }
});
let open9 = false
$('.t-address').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-address').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-address").value = this.value.replace(/\s/,''))){
        open9 = false
    }else{
        open9 = true
    }
});
let open10 = false
$('.t-ass').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-ass').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-ass").value = this.value.replace(/\s/,''))){
        open10 = false
    }else{
        open10 = true
    }
});
let open11 = false
$('.t-qq').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-qq').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-qq").value = this.value.replace(/\s/,''))){
        open11 = false
    }else{
        open11 = true
    }
});
let open12 = false
$('.t-yan').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-yan').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-yan").value = this.value.replace(/\s/,''))){
        open12 = false
        console.log(open12)
    }else{
        open12 = true
    }
});
let open13 = false
$('.t-duan').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-duan').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-duan").value = this.value.replace(/\s/,''))){
        open13 = false
    }else{
        open13 = true
    }
});
$('.t-in').click(function(){

    if(open && open1 && open2 && open3 && open4 && open5 && open6 && open7 && open8 && open9 && open10 && open11 && open12 && open13){
        pAjax({
            url: '../server/t-register.php',
            type: 'post',
            data: {
                username: $('.t-user').prop('value'),
                password: $('.t-word').prop('value')
            }
        }).then(function (res) {
            let json = JSON.parse(res)
            alert(json.msg)
        }) 
        window.location.href = 't-sign.html'
    }
})